package org.jkuang.qstar.commons.jni;

import java.util.concurrent.atomic.AtomicInteger;

public  class CurMap extends Native {
	static AtomicInteger seq = new AtomicInteger(0);
	private int index = seq.getAndIncrement();

	public CurMap(int part, int node_per_page,int node_avg_data) {
		create(index, part,node_per_page,node_avg_data);
	}

	public int put(long key, byte[] value) {
		return put(index, key, value);
	}

	public int remove(long key) {
		return remove(index, key);
	}

	public byte[] get(long key) {
		return get(index, key);
	}


	public void destroy() {
		destroy(index);
	}

	@Override
	protected void finalize() throws Throwable {
		// TODO Auto-generated method stub
		super.finalize();
		destroy();
	}

	private native void create(int index,int part, int node_per_page,int node_avg_data);

	private native void destroy(int index);

	private native int put(int index, long key, byte[] value);

	private native byte[] get(int index, long key);

	private native int remove(int index, long key);

}